<%--
  Created by IntelliJ IDEA.
  User: 陌·笙
  Date: 2019-01-13
  Time: 10:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>销售排行统计</title>
    <jsp:include page="/comm/tag.jsp"/>
  </head>
<body>
<div style="margin-left: 50px;margin-right: 50px">
<div id="main" style="width: 100%;height:800px; padding-top: 50px"></div>
</div>
<script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'));

   /* // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);*/

    $.post('/tongji/xiaoshouTop5',function (data){
        i=0;
        k=0;
       /* console.log(data);*/
        var iphoneName=new Array(5);
        var counts=new Array(15);
        $.each(data.repertoryNames,function(){
            iphoneName[i]=this;
            i++;
        });
        $.each(data.sums,function(){
            counts[k]=this;
            k++;
        });
/*       alert(data.name);
        alert(data.sum);*/
        myChart.setOption({
            title: {
                text: '近半年销售量排行TOP5'
            },
            legend: {},
            tooltip: {},
            dataset: {
                source: [
                    ['product', '近半年', '上个月', '本月'],
                    [iphoneName[0].toString(),parseInt(counts[0]),parseInt(counts[1]),parseInt(counts[2])],
                    [iphoneName[1].toString(),parseInt(counts[3]),parseInt(counts[4]),parseInt(counts[5])],
                    [iphoneName[2].toString(),parseInt(counts[6]),parseInt(counts[7]),parseInt(counts[8])],
                    [iphoneName[3].toString(),parseInt(counts[9]),parseInt(counts[10]),parseInt(counts[11])],
                    [iphoneName[4].toString(),parseInt(counts[12]),parseInt(counts[13]),parseInt(counts[14])]
                ]
            },
            xAxis: {type: 'category'},
            yAxis: {},
            // Declare several bar series, each will be mapped
            // to a column of dataset.source by default.
            series: [
                {type: 'bar'},
                {type: 'bar'},
                {type: 'bar'}
            ]
        })
        myChart.hideLoading();
    })
</script>
</body>
</html>
